package cn.bjsxt.oop.polymorphism;

public class Test {
	public static void testAnimalVoice(Animal c){
		c.voice();
		if (c instanceof Cat) {
			((Cat) c).catchMouse();
		}
	}
	
/*	public static void testAnimalVoice(Dog c){
		c.voice();
	}
	
	public static void testAnimalVoice(Pig c){
		c.voice();
	}
*/	
	public static void main(String[] args){
		Animal c = new Cat();
		Animal d = new Dog();
		Animal p = new Pig();
		Animal t = new Tiger();
		testAnimalVoice(c);
		testAnimalVoice(d);
		testAnimalVoice(p);
		testAnimalVoice(t);
		
		Cat c2 = (Cat)c;
		c2.catchMouse();
		
	}
}
